#include <stdio.h>

void sort(int *arr, int size) {
    int temp;
    for (int i = 0; i < size - 1; i += 2) {
        for (int j = i + 2; j < size; j += 2) {
            if (arr[i] > arr[j]) {
                temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
    }
}

int main() {
    int arr[100];
    int size = 0;
    printf("请输入元素个数（最多100个）：");
    scanf("%d", &size);
    printf("请输入%d个整数：\n", size);
    for (int i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    sort(arr, size);
    printf("排序后的奇数序列：");
    for (int i = 0; i < size - 1; i += 2) {
        printf("%d ", arr[i]);
    }
    printf("\n");
    printf("排序后的偶数序列：");
    for (int i = 1; i < size - 1; i += 2) {
        printf("%d ", arr[i]);
    }
    printf("\n");
    return 0;
}